package by.semerikov.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm; 
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage; 


public class CreateTripForm extends ActionForm{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String name;
	private String description;
	private String from;
	private String to;
	private String cost;
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
	    if (name == null || "".equals(name)) {
	        errors.add("name", new ActionMessage("error.createTrip.name"));
	    }
	    if (from == null  || "".equals(from)) {
	        errors.add("from", new ActionMessage("error.createTrip.from"));
	    }
	    if (to == null  || "".equals(to)) {
	        errors.add("to", new ActionMessage("error.createTrip.to"));
	    }
	    if (cost == null  || "".equals(cost)) {
	        errors.add("cost", new ActionMessage("error.createTrip.cost"));
	    }
	    return errors;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getFrom() {
		return from;
	}
	public void setFrom(String from) {
		this.from = from;
	}
	public String getTo() {
		return to;
	}
	public void setTo(String to) {
		this.to = to;
	}
	public String getCost() {
		return cost;
	}
	public void setCost(String cost) {
		this.cost = cost;
	}
	
}
